﻿using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using MedicalPCTerminal.Write.API.Appcation.Commands.基础设置;
using MedicalPCTerminal.Write.API.Appcation.Commands.知识管理;
using Microsoft.AspNetCore.Authorization;
using MedicalPCTerminal.Write.API.Appcation.Commands.诊疗管理;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MedicalPCTerminal.Write.API.Appcation.Commands.BasicSettings;
using MedicalPCTerminal.Write.API.Appcation.Commands.KnowledgeManagement;
using MedicalPCTerminal.Write.API.Appcation.Commands.DiagnosisTreatment;

namespace MedicalPCTerminal.Write.API.Controllers
{
    /// <summary>
    /// 基础设置的控制器-写
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize]
    public class BasicSettingsController : ControllerBase
    {
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <summary>
        /// <param name="mediator"></param>
        public BasicSettingsController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        #region 基础设置



        #region 团队管理
        /// <summary>
        /// 基础设置--团队管理的添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> TeamInfoAdd(TeamInfoAddCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 基础设置--团队管理的逻辑删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> TeamInfoDel(DelTeamInfoCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 基础设置--团队管理的状态更改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> UdpTeamStatus(UdpTeamStatusCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception ex)
            {

                throw;
            }
        }
        /// <summary>
        /// 基础设置--团队管理的数据更改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> UdpTeamInfo(UdpTeamInfoCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception ex)
            {

                throw;
            }
        }
        #endregion

        #region 设备管理
        /// <summary>
        /// 基础设置--设备管理的数据增加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddDeviceInfo(AddDeviceCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 基础设置--设备管理的数据逻辑删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> DelDeviceInfo(DelDeviceCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        ///  基础设置--设备管理的数据修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> UdpDeviceInfo(UdpDeviceCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        ///  基础设置--设备管理的状态更改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> UdpDeviceStatus(UdpDeviceStatusCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }


        #endregion



        /// <summary>
        /// 基础设置-种病管理添加
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> AddManageMent(AddDiseaseManagementCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 基础设置-种病管理删除
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> DeleteDiseaseManagement(DeleteDiseaseManagementCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 基础设置-种病管理修改
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdateDiseaseManagement(UpdateDiseaseManagementCommand request, CancellationToken cancellationToken)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 基础设置-慢病指标添加
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> AddDiseaseIndicators(AddDiseaseIndicatorsCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 基础设置-慢病指标删除
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> DeleteDiseaseIndicators(DeleteDiseaseIndicatorsCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 基础设置-慢病指标修改
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<int>> HaUpdateDiseaseIndicatorsndle(UpdateDiseaseIndicatorsCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 基础设置-转诊配置
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回受影响的行数</returns>
        [HttpPost]
        public async Task<APIResult<object>> AddInstitution(AddInstitutionCommand request, CancellationToken cancellationToken)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 删除转诊配置
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<object>> DelInstitution([FromQuery] DelInstitutionCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
        #endregion
        #region 指标分类



        /// <summary>
        /// 指标分类的添加和修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> AddIndexClass(AddIndexClassCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 指标分类的删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelIndexClass(DelIndexClassCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 指标定义的添加和修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> AddIndexDefine(AddIndexDefineCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 指标定义的删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelIndexDefine(DelIndexDefineCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }



        #endregion

        #region  知识管理
        /// <summary>
        /// 知识管理-我的知识数据增加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddKnowledgeInfo(AddKnowledgeCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        #endregion

        #region 采集管理

        /// <summary>
        /// 采集管理-添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddColl(AddCollectionManagementCommand request, CancellationToken cancellationToken)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        #endregion
    }
}
